/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright(c) 2021 Huawei Technologies Co., Ltd */

#ifndef HINIC3_XSP_H
#define HINIC3_XSP_H

#include "hinic3_ipsec.h"

struct hinic3_xfrm_sp_key {
	union {
		__be32 a4;
		__be32 a6[4];
	} saddr;

	union {
		__be32 a4;
		__be32 a6[4];
	} daddr;

	u8	proto;
};

/* IPsec SA Item */
struct hinic3_xfrm_sp {
	struct hlist_node hlist; /* Item in SPDB hashtable */
	u32 spi;
	u8 ipsec_proto; /* qpc context priv */
	struct xfrm_policy *xp;
};

/* IPsec SA Database */
struct hinic3_xfrm_spd {
	struct hlist_head spdb[HINIC3_IPSEC_SP_HASH_TBL_SIZE];
	spinlock_t spdb_lock; /* lock SPD */
	bool inited;
};

extern struct hinic3_xfrm_spd g_hinic3_spd;

struct hinic3_xfrm_sp *hinic3_search_sp_by_key(struct hinic3_xfrm_sp_key *sp_key, bool ipv4);

#endif /* _HINIC3_XSP_H_ */
